import { SerializeClass, Serialize, CSMemberType } from "../../core/serialize";
import { Action } from "./action";
import { ECABase } from "./eca_base";

@SerializeClass("Condition")
export class Condition extends ECABase {
    @Serialize()
    isNot = false;
    @Serialize(Action, CSMemberType.Array)
    actions: Action[] = [];

    check(obj: any, ...args: any[]): boolean {
        let b = this.onCheck(obj, ...args);
        return this.isNot ? !b : b;
    }

    onCheck(obj: any, ...args: any[]): boolean {
        return true;
    }
};